package com.gin.pixiv.interceptor

import com.gin.pixiv.main.Pixiv
import okhttp3.Interceptor
import okhttp3.Response

/**
 * 添加Cookie的拦截器
 * @author bx002
 * @since 2024/2/18 11:53
 */
class CookieInterceptor(private val phpSessionId: String) : Interceptor {
    override fun intercept(chain: Interceptor.Chain): Response {
        val request = chain.request().newBuilder()
            .addHeader("cookie", "PHPSESSID=$phpSessionId")
            .addHeader("referer", Pixiv.DEFAULT_HOST)
            .build()
        return chain.proceed(request)
    }
}